package com.cloudkinto.common.utils;

import com.cloudkinto.common.common.DateFormater;


import java.util.Date;
import java.util.Random;

/**
 * @author fanp
 * @version v1.0.0
 * @Description : 优惠券随机码
 * @Create on : 2021/2/8 16:02
 **/
public class PromoCode {

    private static char[] codeSequence = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R',
            'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
    private static int number=3;
    public static String coed(){
        Date date = new Date();
        String time = DateFormater.formatSecond(date);
        StringBuffer stringBuffer=new StringBuffer();
        for (int i = 0; i < number; i++) {
           Random random=new Random();
            int a = random.nextInt(codeSequence.length-1);
            stringBuffer.append(codeSequence[a]);
        }
        stringBuffer=stringBuffer.append(time);
        return stringBuffer.toString();
    }
}
